import { Controller, Get, Param, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from "@nestjs/swagger";

import { JwtAuthGuard } from "../auth/guards/jwt-auth.guard";
import { ProjectDetailDto } from "./dto/project-detail.dto";
import { ProjectSummaryDto } from "./dto/project-summary.dto";
import { ProjectsService } from "./projects.service";

@Controller("projects")
@UseGuards(JwtAuthGuard)
@ApiTags("Projects")
@ApiBearerAuth()
export class ProjectsController {
  constructor(private readonly projectsService: ProjectsService) {}

  @Get()
  @ApiOperation({ summary: "获取项目列表" })
  @ApiOkResponse({ type: [ProjectSummaryDto] })
  findAll() {
    return this.projectsService.findAll();
  }

  @Get(":id")
  @ApiOperation({ summary: "获取项目详情" })
  @ApiOkResponse({ type: ProjectDetailDto })
  findOne(@Param("id") id: string) {
    return this.projectsService.findOne(id);
  }
}
